﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;

namespace TeamFoundation.ContinuousMerge
{
    public partial class MainService : ServiceBase
    {
        Runtime _runtime;

        public MainService()
        {
            InitializeComponent();

            RuntimeConfiguration config = new RuntimeConfiguration();
            config = config.SetConfiguration("ConnectionString", "Data Source=localhost;Initial Catalog=tfcms;Integrated Security=True");
            _runtime = new Runtime(config);
        }

        internal void Start(string[] args)
        {
            OnStart(args);
        }

        protected override void OnStart(string[] args)
        {
            _runtime.PostTask(new Tasks.RefreshConfigurationTask());
            _runtime.Run();
        }

        protected override void OnStop()
        {
            _runtime.Stop();
        }

        protected override void OnPause()
        {
            _runtime.Pause();
        }

        protected override void OnContinue()
        {
            _runtime.Continue();
        }
    }
}
